<template>
  <div
    class="buttonsContainer"
    :style="{
      paddingBottom: tempData.paddingBottom + 'px',
      paddingLeft: tempData.paddingTwice + 'px',
      paddingRight: tempData.paddingTwice + 'px',
      paddingTop: tempData.paddingTop + 'px',
      boxSizing: 'border-box',
    }"
  >
    <div
      class="cardBtnBoxLeft"
      :style="
        tempData.showType == 1
          ? {
              borderTopLeftRadius: tempData.radiusNumTop + 'px',
              borderTopRightRadius: tempData.radiusNumTop + 'px',
              borderBottomLeftRadius: tempData.radiusNumBottom + 'px',
              borderBottomRightRadius: tempData.radiusNumBottom + 'px',
              backgroundColor: tempData.boxBg,
            }
          : {
              borderTopLeftRadius: tempData.radiusNumTop + 'px',
              borderTopRightRadius: tempData.radiusNumTop + 'px',
              borderBottomLeftRadius: tempData.radiusNumBottom + 'px',
              borderBottomRightRadius: tempData.radiusNumBottom + 'px',
              backgroundImage: 'url(' + tempData.bgImage + ')',
              backgroundSize: '100% 100%',
            }
      "
    >
      <div
        class="tags"
        v-show="btnList[0].tag"
        :style="{ background: btnList[0].tagBg, color: btnList[0].tagColor }"
      >
        {{ btnList[0].tagText }}
      </div>
      <p class="names" :style="{ color: tempData.fontColor }">
        {{ btnList[0].name }}
      </p>
      <p class="gotos">点击进入 <icon-right style="color: #86909c; font-size: 10px" /></p>
      <img class="btnImg" :src="btnList[0].img" alt="" />
    </div>
    <div class="cardBtnBoxRight">
      <div
        class="right1"
        :style="
          tempData.showType == 1
            ? {
                borderTopLeftRadius: tempData.radiusNumTop + 'px',
                borderTopRightRadius: tempData.radiusNumTop + 'px',
                borderBottomLeftRadius: tempData.radiusNumBottom + 'px',
                borderBottomRightRadius: tempData.radiusNumBottom + 'px',
                backgroundColor: tempData.boxBg,
              }
            : {
                borderTopLeftRadius: tempData.radiusNumTop + 'px',
                borderTopRightRadius: tempData.radiusNumTop + 'px',
                borderBottomLeftRadius: tempData.radiusNumBottom + 'px',
                borderBottomRightRadius: tempData.radiusNumBottom + 'px',
                backgroundImage: 'url(' + tempData.bgImage + ')',
                backgroundSize: '100% 100%',
              }
        "
      >
        <div
          class="tags"
          v-show="btnList[1].tag"
          :style="{ background: btnList[1].tagBg, color: btnList[1].tagColor }"
        >
          {{ btnList[1].tagText }}
        </div>
        <div class="namesGo">
          <p class="names" :style="{ color: tempData.fontColor }">
            {{ btnList[1].name }}
          </p>
          <p class="gotos">点击进入 <icon-right style="color: #86909c; font-size: 10px" /></p>
        </div>
        <img class="btnImg" :src="btnList[1].img" alt="" />
      </div>
      <div
        class="right1"
        :style="
          tempData.showType == 1
            ? {
                borderTopLeftRadius: tempData.radiusNumTop + 'px',
                borderTopRightRadius: tempData.radiusNumTop + 'px',
                borderBottomLeftRadius: tempData.radiusNumBottom + 'px',
                borderBottomRightRadius: tempData.radiusNumBottom + 'px',
                backgroundColor: tempData.boxBg,
              }
            : {
                borderTopLeftRadius: tempData.radiusNumTop + 'px',
                borderTopRightRadius: tempData.radiusNumTop + 'px',
                borderBottomLeftRadius: tempData.radiusNumBottom + 'px',
                borderBottomRightRadius: tempData.radiusNumBottom + 'px',
                backgroundImage: 'url(' + tempData.bgImage + ')',
                backgroundSize: '100% 100%',
              }
        "
        style="margin-bottom: 0px"
      >
        <div
          class="tags"
          v-show="btnList[2].tag"
          :style="{ background: btnList[2].tagBg, color: btnList[2].tagColor }"
        >
          {{ btnList[2].tagText }}
        </div>
        <div class="namesGo">
          <p class="names" :style="{ color: tempData.fontColor }">
            {{ btnList[2].name }}
          </p>
          <p class="gotos">点击进入 <icon-right style="color: #86909c; font-size: 10px" /></p>
        </div>
        <img class="btnImg" :src="btnList[2].img" alt="" />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import btn2 from '@/assets/didaima/gengduo.png'
  import { watch, ref, onMounted } from 'vue'
  const props = defineProps({
    // 选中的当前组件参数
    compObj: {
      type: Object,
      default: () => {
        return {}
      },
    },
  })
  const tempData: any = ref({})
  const btnList: any = ref([])
  const items = ref()
  watch(
    () => props.compObj,
    (newVal, oldVal) => {
      tempData.value = JSON.parse(JSON.stringify(newVal))
      btnList.value = tempData.value.btnList.filter((item) => item.status !== 1)
      console.log(tempData.value)
      if (tempData.value.showMore && btnList.value.length > 3) {
        const newItem = {
          name: '更多功能',
          img: btn2,
          tag: false,
          link: '/pages/home/balance',
          tagBg: '#ff0000',
          status: 0,
          tagColor: '#ffffff',
          showChooseColor1: false,
          showChooseColor2: false,
        }
        // 使用splice方法在第三条数据的位置插入新对象
        btnList.value.splice(2, 0, newItem)
      } else {
        if (btnList.value[2].name == '更多功能') {
          btnList.value.splice(2, 1)
        }
      }

      // return a
    },
    { immediate: true, deep: true }
  )
</script>

<style scoped lang="less">
  .buttonsContainer {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    .cardBtnBoxLeft {
      width: 140px;
      height: 164px;
      padding: 20px;
      box-sizing: border-box;
      background-color: #fff;
      border-radius: 10px;
      position: relative;

      .tags {
        width: auto;
        border-radius: 6px;
        font-size: 10px;
        line-height: 12px;
        padding: 2px 4px;
        box-sizing: border-box;
        text-align: center;
        position: absolute;
        top: 10px;
        right: 10px;
      }
      .names {
        font-size: 16px;
        color: #1d1929;
        font-weight: bold;
      }
      .gotos {
        font-size: 10px;
        color: #86909c;
        margin-bottom: 10px;
      }
      .btnImg {
        width: 90px;
        height: 90px;
      }
    }
    .cardBtnBoxRight {
      width: calc(100% - 150px);
      .right1 {
        width: 100%;
        height: 77px;
        margin-bottom: 10px;
        background-color: #fff;
        border-radius: 10px;
        padding: 20px;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;

        .tags {
          width: auto;
          border-radius: 6px;
          font-size: 10px;
          line-height: 12px;
          padding: 2px 4px;
          box-sizing: border-box;
          text-align: center;
          position: absolute;
          top: 10px;
          right: 10px;
        }
        .namesGo {
          width: calc(100% - 50px);
          .names {
            font-size: 16px;
            color: #1d1929;
            font-weight: bold;
          }
          .gotos {
            font-size: 10px;
            color: #86909c;
          }
        }
        .btnImg {
          width: 50px;
          height: 50px;
        }
      }
    }
  }
</style>
